﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IceCreamCalculator
{
    class Program
    {


        static void Main(string[] args)
        {
            string menu = "1. Spring\n2. Summer\n3. Autumn\n4. Winter\n5. Exit Application";
            // Seasons and total costs for material
            int spring = 12000;
            int summer = 9000;
            int autumn = 13000;
            int winter = 15000;
            int input;
            int season;
            int amountOfIcecream;

            // Price per ice cream
            int íceCreamCost = 20;

            do
            {
                // Reset variables
                amountOfIcecream = 0;
                generateMenu(menu);

                do
                {
                    input = 0;

                    Console.Write("Pick season: ");
                    try
                    {
                        input = int.Parse(Console.ReadLine());
                        if (input > 5 || input < 1)
                        {
                            throw new ArgumentException();
                        }
                    }
                    catch (Exception)
                    {
                        Console.Clear();
                        generateMenu(menu);
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Not a valid number, try again!");
                        Console.ForegroundColor = ConsoleColor.Gray;
                    }

                } while (input > 5 || input < 1);

                if (input == 5)
                {
                    break;
                }

                switch (input)
                {
                    case 1:
                        season = spring;
                        break;
                    case 2:
                        season = summer;
                        break;
                    case 3:
                        season = autumn;
                        break;
                    case 4:
                        season = winter;
                        break;
                    default:
                        season = 0;
                        break;
                }

                do
                {
                    try
                    {
                        Console.Write("Ice creams sold: ");
                        amountOfIcecream = int.Parse(Console.ReadLine());
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Not a valid number, try again!");
                        Console.ForegroundColor = ConsoleColor.Gray;
                    }
                } while (amountOfIcecream == 0);

                Console.Clear();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Revenue for selected season: {0}SEK", (amountOfIcecream * íceCreamCost) - season);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Would you like to calculate another season? \nPress any key to restart or press \"N\" to exit the application");
            } while (Console.ReadKey(true).Key != ConsoleKey.N);

        }
        static void generateMenu(string menu)
        {
            Console.WriteLine("***************");
            Console.WriteLine(menu);
            Console.WriteLine("***************");
        }
    }
}
